package com.fen.testdemo;

import org.junit.Test;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class TestDemo {
    public static void main(String[] args) {
//        int i1 = 3;
//        int i2 = i1;
//        i2 = 4;
//        System.out.print("i1==" + i1);
//        System.out.println(" but i2==" + i2);
//        Value v1 = new Value();
//        v1.val = 5;
//        Value v2 = v1;
//        v2.val = 6;
//        System.out.print("v1.val==" + v1.val);
//        System.out.println(" and v2.val==" + v2.val);
//        int a = 1/0;
//        System.out.println("args = " + args);
    }

    @Test
    public void test01() {
        CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
            String s = "abcdefgh";
            return s;
        }).thenCompose(param -> CompletableFuture.supplyAsync(() -> {
            System.out.println("param = " + param.substring(3));
            return param;
        }));
        String result = "";
        try {
            result = future.get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
        System.out.println("result = " + result);
    }
}
